package nan.String;

public class Main2 {
    public static void main(String[] args) {
        String str="abcd";
//        for(int i=0;i<10;i++){
//            StringBuilder ss=new StringBuilder();
//            ss.append(str).append(i);
//            str=ss.toString();
//        }
//        System.out.println(str);
        StringBuilder ss=new StringBuilder();
        ss.append(str);
        for(int i=0;i<10;i++){
            ss.append(i);
            str=ss.toString();
       }
        System.out.println(str);
    }
    public static void main1(String[] args) {
//        String string="abcd";
//        string+="nan";
//        System.out.println(string);
        System.out.println("==================");
       String string="abcd";
        StringBuilder a2=new StringBuilder();//调用构造方法
        a2.append(string).append("nan");//所有的append放到了a2中
        string=a2.toString();
        System.out.println(string);

        StringBuffer a=new StringBuffer("abcd");
        System.out.println(a.append("nan"));

        StringBuilder a3=new StringBuilder("abcd");
        System.out.println(a3.append("nan"));
    }
}
